package com.opener.web.acl.dao;

import com.opener.web.acl.model.SysFunction;
import com.opener.web.acl.model.UserRole;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by baboy on 01/12/2016.
 */
@Repository
public interface AclDao {

    List<SysFunction> getAllFunctions();

    UserRole getRole(Integer id);
    UserRole getRoleByKey(String key);
    Integer getSearchRolesCount(@Param("name") String name);
    List<UserRole> searchRoles(@Param("name") String name, @Param("offset") int offset, @Param("pageSize") int pageSize);
    boolean createRole(UserRole role);
    boolean updateRole(UserRole role);
    boolean updateRoleStatus(UserRole role);
    boolean removeRole(int roleId);

    boolean addRoleFunctions(@Param("roleId") int roleId, @Param("functionIds") List<Integer> functionIds);
    boolean removeRoleFunctions(int roleId);
    List<SysFunction> getRoleFunctions(int roleId);

    List<UserRole> getUserRoles(Long uid);
    boolean removeUserRoles(@Param("uid") Long uid, @Param("roles") List<Integer> roles);
    boolean removeAllUserRoles(@Param("uid") Long uid);
    boolean addUserRoles(@Param("uid") Long uid, @Param("roles") List<UserRole> roles);
}
